package com.example.petshopping.ui.address.model;

import java.io.Serializable;
import java.util.Objects;

public class Address implements Serializable {
    
    private String id;
    private String name;
    private String phone;
    private String province;
    private String city;
    private String district;
    private String detailAddress;
    private boolean isDefault;
    
    public Address() {
        // Default constructor
    }
    
    public Address(String id, String name, String phone, String province, String city, String district, String detailAddress, boolean isDefault) {
        this.id = id;
        this.name = name;
        this.phone = phone;
        this.province = province;
        this.city = city;
        this.district = district;
        this.detailAddress = detailAddress;
        this.isDefault = isDefault;
    }
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getProvince() {
        return province;
    }
    
    public void setProvince(String province) {
        this.province = province;
    }
    
    public String getCity() {
        return city;
    }
    
    public void setCity(String city) {
        this.city = city;
    }
    
    public String getDistrict() {
        return district;
    }
    
    public void setDistrict(String district) {
        this.district = district;
    }
    
    public String getDetailAddress() {
        return detailAddress;
    }
    
    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress;
    }
    
    public boolean isDefault() {
        return isDefault;
    }
    
    public void setDefault(boolean isDefault) {
        this.isDefault = isDefault;
    }
    
    public String getFullAddress() {
        StringBuilder builder = new StringBuilder();
        if (province != null && !province.isEmpty()) {
            builder.append(province);
        }
        if (city != null && !city.isEmpty()) {
            builder.append(" ").append(city);
        }
        if (district != null && !district.isEmpty()) {
            builder.append(" ").append(district);
        }
        if (detailAddress != null && !detailAddress.isEmpty()) {
            builder.append(" ").append(detailAddress);
        }
        return builder.toString();
    }
    
    public String getRegionText() {
        StringBuilder builder = new StringBuilder();
        if (province != null && !province.isEmpty()) {
            builder.append(province);
        }
        if (city != null && !city.isEmpty()) {
            builder.append(" ").append(city);
        }
        if (district != null && !district.isEmpty()) {
            builder.append(" ").append(district);
        }
        return builder.toString();
    }
    
    public String getContactInfo() {
        return name + " " + phone;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Address address = (Address) o;
        return Objects.equals(id, address.id);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
} 